package cn.kgc;

/**
 * @author 郝雷蒙
 * @Description
 * @date 2020/12/4 12:11
 */
public class ICBC implements Bank{

    /**
     * 年利率为4%，每月利率为 0.04/12
     */
    public static final double rate = 0.03 / 12;

    /**
     * 卡内金额 默认为0.0元
     */
    public static double principal = 0.0;

    @Override
    public double saveMoney(double money, int month) {
        //当存取时间不满一年时，years = days / 365  or  years = month / 12;
        //return principal += money * Math.pow(rate + 1, month)
        return principal = principal + money + money * rate * month;
    }

    /**
     * 取款之后的本息
     *
     * @param month
     */
    public void save(int month) {
        principal = principal + principal * rate * month;
    }

    @Override
    public double drowMoney(double money) {
        return principal -= money;
    }

    @Override
    public double query() {
        return principal;
    }
}
